<?php
    class DirPresentation {
        function __construct() {
        }
              
        function Insert() {
            print "
                  <form name=\"INSERT_IMG\" action=\"MainAdminWnd.php\" method=\"POST\" enctype=\"multipart/form-data\">
                  Vytvoriť Fotoalbum :
                  <table><tr><td>
                      Súbor: </td><td> <input type=\"text\" name=\"DIRNAME\" value=\"\" />
                        </td><td>
                      Názov: </td><td> <input type=\"text\" name=\"NAME\" value=\"\" /> 
                        </td><td>
                      Popis: </td><td> <textarea name=\"DESCRIPTION\" rows=\"2\" cols=\"20\" /></textarea>
                        </td><td>
                      <input type=\"submit\" value=\"Vytvoriť\" name=\"INSERT\" />
                  </td></tr></table>
                  <input type=\"hidden\"  name=\"ACTION\" value=\"INSERT_DIR\" />
                  </form>
                  <hr>
                  ";
        }
        
        function Update($ItemFolder) {
            print "
                  <form name=\"$ItemFolder->dirName\" action=\"MainAdminWnd.php\" method=\"POST\" enctype=\"multipart/form-data\">
                  <table><tr><td>
                      Súbor: </td><td> <input type=\"text\"  name=\"DIRNAME\" value=\"$ItemFolder->dirName\" />
                        </td><td>
                      Názov: </td><td> <input type=\"text\" name=\"NAME\" value=\"$ItemFolder->name\" /> 
                        </td><td>
                      Popis: </td><td> <textarea name=\"DESCRIPTION\" rows=\"2\" cols=\"20\" />$ItemFolder->description</textarea>
                        </td><td>
                      <input type=\"submit\" value=\"Uložiť\" name=\"SAVE$ItemFolder->dirName\" />
                  </td></tr></table>
                  <input type=\"hidden\"  name=\"OLD_DIRNAME\" value=\"$ItemFolder->dirName\" />
                  <input type=\"hidden\"  name=\"ACTION\" value=\"UPDATE_DIR\" />
                  </form>
                  <form name=\"$ItemFolder->dirName\" action=\"MainAdminWnd.php\" method=\"POST\" enctype=\"multipart/form-data\">
                  <input type=\"submit\" value=\"Zmazať $ItemFolder->dirName\" name=\"DEL$ItemFolder->dirName\" />
                  <input type=\"hidden\"  name=\"DIRNAME\" value=\"$ItemFolder->dirName\" />
                  <input type=\"hidden\"  name=\"ACTION\" value=\"DELETE_DIR\" />
                  </form>
                  <hr>
                  ";
        }
        
        public function Select($Dirs,$selectedDir)
        {
            print "<form name=\"Disrs\" action=\"MainAdminWnd.php\" method=\"POST\" enctype=\"multipart/form-data\">
                    Vybrať Fotoalbum : 
                    <select onChange=\"this.form.submit();\" name=\"DIRNAME\">";
                    foreach ($Dirs as $folder) {
                        if($folder == $selectedDir)
                          print "<option value=\"$folder\" selected=\"selected\">$folder</option>";
                        else
                          print "<option value=\"$folder\" >$folder</option>";
                        }
                   print "
                    </select>
                    
                    </form>
            ";//<input type=\"submit\" value=\"Zobraziť\" name=\"SELECT\" />
        }
        
        function ReqSELECTED() {
            if($_REQUEST["DIRNAME"]!="")
                return $_REQUEST["DIRNAME"];
        }
                                
        function ReqDELETE() {
            if($_REQUEST["ACTION"]=="DELETE_DIR")
                return $_REQUEST["DIRNAME"];
        }
        
        function ReqUPDATE(&$OldDirname) {
            if($_REQUEST["ACTION"]=="UPDATE_DIR")
            {
                $result = new ItemFolder();
                $result->dirName = $_REQUEST["DIRNAME"];
                $result->name =   $_REQUEST["NAME"];
                $result->description = $_REQUEST["DESCRIPTION"];
                $OldDirname = $_REQUEST["OLD_DIRNAME"];
                return $result;
            }
            else
                return "";
        }
        
        function ReqINSERT() {
            if($_REQUEST["ACTION"]=="INSERT_DIR")
            {
                $result = new ItemFolder();
                $result->dirName = $_REQUEST["DIRNAME"];
                $result->name =   $_REQUEST["NAME"];
                $result->description = $_REQUEST["DESCRIPTION"];
                return $result;
            }
            else
                return "";
        }
        
        function __destruct() {
        }
    }
?>
